/*****************************************************************************
 *   Copyright 2011 ZHUANG Yuan              	                             *
 *   SudokuITS as Final Year Project for BScCS, City University of Hong Kong *
 *                                      									 *
 *   Licensed under the Apache License, Version 2.0 (the "License");         *
 *   you may not use this file except in compliance with the License.        *
 *   You may obtain a copy of the License at                                 *
 *                                                                           *
 *   http://www.apache.org/licenses/LICENSE-2.0                              *
 *                                                                           *
 *   Unless required by applicable law or agreed to in writing, software     *
 *   distributed under the License is distributed on an "AS IS" BASIS,       *
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
 *   See the License for the specific language governing permissions and     *
 *   limitations under the License.                                          *
 *****************************************************************************/

package android.sudoku.its.views;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.sudoku.its.util.GameVariables;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

/**
 * Sudoku Entry Page
 * @author 51158282
 *
 */
public class EntryPage extends Activity implements OnClickListener {	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		// Set layout for Entry Page
		setContentView(R.layout.entry);
		
		// Set onClickListener for buttons
		ImageView loginButton = (ImageView) findViewById(R.id.entry_page_login_button);
		loginButton.setOnClickListener(this);
		ImageView registerButton = (ImageView) findViewById(R.id.register_button);
		registerButton.setOnClickListener(this);
		ImageView tryitButton = (ImageView) findViewById(R.id.tryit_button);
		tryitButton.setOnClickListener(this);		
	}	
	
	public void onClick(View v) {
		switch(v.getId()) {
			case R.id.entry_page_login_button:
				startLoginPage();
				break;
			case R.id.register_button:
				startRegisterPage();
				break;
			case R.id.tryit_button:
				startMainMenuPage();
				break;
		}
	}
	
	/**
	 * Go to Login Page
	 */
	private void startLoginPage() {
		Intent i =  new Intent(getBaseContext(), LoginPage.class);
		startActivity(i);
	}
	
	/**
	 * Go to Main Menu Page
	 */
	private void startMainMenuPage() {
		Intent i =  new Intent(getBaseContext(), MainMenuPage.class);
		i.putExtra(MainMenuPage.USER_TITLE, GameVariables.USER_TITLE_GUEST);
		i.putExtra(MainMenuPage.USER_TYPE, MainMenuPage.NEW_USER);
		startActivity(i);
	}
	
	/**
	 * Go to Register Page
	 */
	private void startRegisterPage() {
		Intent i =  new Intent(getBaseContext(), RegisterPage.class);
		startActivity(i);
	}
}
